import { useEffect } from 'react';
import './style.less'
import { Button, Table } from 'antd';
import Content from './content'
import {  useSelector, useDispatch } from 'react-redux'
import {tranDeviceToTable, columns} from './helper'
import { setEnvReady } from '@/store'

function Sign() {
    const dispatch = useDispatch();
    const envReady = useSelector((state) => tranDeviceToTable(state.envReady));  //当前连接的设备信息
    useEffect(()=>{
        dispatch(setEnvReady()) // 每次加载路由 都要检查，避免中途卸载驱动
    },[])
    return <div className='sign'>
        {envReady?.every(it => it.status) ? <Content /> : <>
            <div className='desc'>
                签名依赖以下三个软件，出于总总考虑没有没集成到软件中，需用户自行安装。<br />
            </div>
            <div>
                <Table columns={columns} dataSource={envReady} pagination={false} bordered />
            </div>
            <Button type="primary" className='mt-2' onClick={()=>{dispatch(setEnvReady())}}>重新检测</Button>
        </>}
    </div>
}

export default Sign;